Motor shields are attachments to Arduinos that let motors that need extra power to be connected and controlled. It takes in an external power source that supplies power to the motor, while still allowing the speed of the motors to be controlled by the Arduino.
#include <Wire.h> #include <Adafruit_MotorShield.h> Adafruit_MotorShield AFMS = Adafruit_MotorShield(); Adafruit_DCMotor *myMotor = AFMS.getMotor(1); Adafruit_DCMotor *myMotor2 = AFMS.getMotor(2); void setup() { AFMS.begin(); } void loop() { myMotor->setSpeed(255); myMotor->run(FORWARD); delay(1000); }